<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置采集群</title>
  <meta name="renderer" content="webkit">
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  @include('public.style')

</head>
<body>
           @include('public.navbar')



<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>设置采集群</legend>
</fieldset>
<div id="test6" class="demo-transfer"></div>

	@include('public.script')
<script>
layui.use(['transfer', 'layer', 'util'], function(){
  var $ = layui.$
  ,transfer = layui.transfer
  ,layer = layui.layer
  ,util = layui.util;

  //模拟数据
var friends = [];
var values = [];
$.ajax({
      async : false,
      type: "get",
      url: "/user/get_friends?status=cj",
      contentType:'application/json;charset=UTF-8',
      headers: {
              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
          },
      error : function(request) {
          layer.msg("error");
      },
      success : function(data) {
          console.log(data.friends);
          console.log(data.values);

          friends = data.friends;
          values = data.values;

      }
  });
  //穿梭时的回调
  transfer.render({
    elem: '#test6'
	,title: ['微信群', '设置发单群']  //自定义标题
	,showSearch: true
	,width: 250
    ,data: friends
	,value: values
	,id: 'key123' //定义唯一索引
    ,onchange: function(obj, index){
      var arr = ['左边', '右边'];
      var getData = transfer.getData('key123'); //获取右侧数据
	  //layer.alert(JSON.stringify(getData));
	  $.ajax({
	              async : false,
	              type: "post",
                  url: "/user/fconfig?status=cj",
	              contentType:'application/json;charset=UTF-8',
	              data: JSON.stringify(getData),
                  headers: {
                          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                      },
	              error : function(request) {
					  layer.msg("error");
	              },
	              success : function(data) {
	                  // alert(data.code);
					  if(data.code == 0){
						  layer.msg("设置采集群成功")
					  }else{
						  layer.msg("error:"+data.msg)
					  }
	              }
	          });

	  //layer.alert('来自 <strong>'+ arr[index] + '</strong> 的数据：'+ JSON.stringify(obj)); //获得被穿梭时的数据
    }
  })


});
</script>


</body>
</html>
